<?php
namespace Management\Model;
use Think\Model;
class BaseModel extends Model {

    public function _initialize(){

        $SITE_VERIFY = C('SITE_VERIFY');
        $domainArr =  $SITE_VERIFY['domain_name'];
        $extra_module_Arr = $SITE_VERIFY['extra_module'];
        $site_code = trim($SITE_VERIFY['site_code']);


//        $verify_code = base64_encode(md5(strtolower(json_encode(array('domainArr'=>$domainArr,'authcode'=>'pangu96877','extra_module'=>$extra_module_Arr)))));
//
//
//        if($verify_code!=$site_code){
//            $this->error("验证码不正确，请联系盘古网络技术有限公司寻找详细咨询");
//        };
//
//
//        $requirehost = strtolower($_SERVER['HTTP_HOST']);
//        $matchflag = false;
//        foreach($domainArr as $item){
//            if(strtolower($item)==$requirehost){
//                $matchflag=true;
//                break;
//            }
//        }
//        if(!$matchflag){
//            $this->error("非正版拷贝或域名设置不正确");
//        }


    }
    public function hasModule($moduleName){
        $SITE_VERIFY = C('SITE_VERIFY');
        $extra_module_Arr = $SITE_VERIFY['extra_module'];
        if(array_search(strtolower($moduleName),array_map("strtolower",$moduleName))!==false){
            return true;
        }
        return false;
    }
    public function listModules(){
        $SITE_VERIFY = C('SITE_VERIFY');
        $extra_module_Arr = $SITE_VERIFY['extra_module'];
        return $extra_module_Arr;
    }

    public function error($errorMsg){
        echo "<html>";
        echo "<meta charset=\"utf-8\" />";
        echo $errorMsg;
        echo "</html>";
        exit();
    }



}
